import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  //设置代理
  server:{
    proxy:{
      '/admin':{//凡是以 /admin 开头的网络请求 都会自动转发到http://180.76.99.14这个目标服务器
        target:'http://180.76.99.14',//目标服务器
        changeOrigin:true,//开启跨域
        rewrite:''
      }
    }
  }
})
